#!/bin/sh
#
# 部署 MongoDB
#

docker pull mongo:latest
# --auth
docker run -itd --name mongo -p 27017:27017 mongo

npm install -g yapi-cli --registry https://registry.npm.taobao.org
cd /usr/local/node/bin/
./yapi server



## 设置密码
#$ docker exec -it mongo mongo admin
## 创建一个名为 admin，密码为 123456 的用户。
#>  db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
## 尝试使用上面创建的用户信息进行连接。
#> db.auth('admin', '123456')

cd /usr/local/node/bin/my-yapi/
# node vendors/server/app.js
npm install -g pm2
pm2 start /usr/local/bin/yapi/vendors/server/app.js
pm2 start /usr/local/node/bin/my-yapi/vendors/server/app.js
pm2 stop /usr/local/node/bin/my-yapi/vendors/server/app.js
# 账号名："admin@admin.com"，密码："ymfe.org"

echo "------------ 部署完成 ------------"